@import "@wordpress/base-styles/breakpoints";
@import "@automattic/typography/styles/variables";
@import "../styles/clear-fix";

// Multisite
.foldable-card.card {
	@include a8c-clear-fix;
	position: relative;
	transition: margin 0.15s linear;
	padding: 0;
}

.foldable-card__header {
	min-height: 64px;
	width: 100%;
	padding: 16px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: relative;

	&.is-clickable.is-expandable {
		cursor: pointer;
	}

	&.has-border {
		.foldable-card__summary,
		.foldable-card__summary-expanded {
			margin-right: 48px;
		}

		.foldable-card__expand {
			border-left: 1px var(--color-neutral-5) solid;
		}
	}
}

.foldable-card.is-compact .foldable-card__header {
	padding: 8px 16px;
	min-height: 40px;
}

.foldable-card.is-expanded .foldable-card__header {
	margin-bottom: 0;
	height: inherit;
	min-height: 64px;
}

.foldable-card.is-expanded.is-compact .foldable-card__header {
	min-height: 40px;
}

.foldable-card.is-disabled .foldable-card__header {
	opacity: 0.2;
}

.foldable-card__action {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
}

.foldable-card.is-expanded .foldable-card__action {
	height: 100%;
}

.foldable-card.is-disabled .foldable-card__action {
	cursor: default;
}

.accessible-focus .foldable-card__action:focus {
	outline: thin dotted;
}

button:not(:disabled).foldable-card__action {
	cursor: pointer;
}

.foldable-card__main {
	max-width: calc(100% - 36px);
	display: flex;
	align-items: center;
	flex: 2 1;
	margin-right: 5px;

	@media (max-width: #{ ($break-mobile) }) {
		flex: 1 1;
	}
}

.foldable-card__secondary {
	display: flex;
	align-items: center;
	flex: 1 1;
	justify-content: flex-end;

	@media (max-width: #{ ($break-mobile) }) {
		flex: 0 1;
	}
}

.foldable-card__expand {
	width: 48px;

	.gridicon {
		display: flex;
		align-items: center;
		width: 100%;
		vertical-align: middle;

		transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s ease-in;
	}

	&:not(:disabled) .gridicon {
		fill: var(--studio-gray-100);
	}

	&:disabled .gridicon {
		fill: var(--studio-gray-20);
	}
}

.foldable-card.is-expanded > .foldable-card__header .foldable-card__expand .gridicon {
	transform: rotate(180deg);
}

.foldable-card__content {
	display: none;
}

.foldable-card.is-smooth .foldable-card__content {
	display: block;
	overflow: hidden;

	transition: max-height 0.25s ease;
	max-height: 0;
}

.foldable-card.is-expanded.is-smooth .foldable-card__content {
	height: auto;
	max-height: 250px; // fallback if not set inline with js
	transition: max-height 0.25s ease;
	padding: 0;
}

.foldable-card.is-expanded .foldable-card__content {
	display: block;
	padding: 16px;
	border-top: 1px solid var(--color-neutral-5);
}

.foldable-card.is-compact .foldable-card.is-expanded .foldable-card__content {
	padding: 8px;
}

.foldable-card__summary,
.foldable-card__summary-expanded {
	margin-right: 40px;
	color: var(--color-text-subtle);
	font-size: $font-body-extra-small;
	transition: opacity 0.2s linear;
	display: inline-block;

	@media (max-width: #{ ($break-mobile) }) {
		display: none;
	}
}

.foldable-card.has-expanded-summary .foldable-card__summary,
.foldable-card.has-expanded-summary .foldable-card__summary-expanded {
	transition: none;
	flex: 2;
	text-align: right;
}

.foldable-card__summary {
	opacity: 1;
	display: inline-block;
}

.foldable-card.is-expanded .foldable-card__summary {
	display: none;
}

.has-expanded-summary .foldable-card.is-expanded .foldable-card__summary {
	display: none;
}

.foldable-card__summary-expanded {
	display: none;
}

.foldable-card.is-expanded .foldable-card__summary-expanded {
	display: inline-block;
}
